<?php
/**
 * Verwalten von Routen
 *
 * @author		Joachim Ruf
 * @copyright	Copyright (c) 2003-2010 Loresoft Software (http://www.loresoft.de)
 * @license		http://yapary.loresoft.de/lizenzbedingungen     New BSD License
 * @TODO es koennte noch ein caching-problem bestehen
 * */


Class Yapary_Route_Route
{
    private $oSql;


    /**
     * Klasse zur Verwaltung von statischen und dynamischen Routen.
     * {Route, Routenname, Controller, Action, URL}
     *
     * http://internetseite.de/?route=routeName
     * routeName => controller=abc, action=xyz
     * */
    function __construct (Yapary_Db_Sql_Connector $_oSql)
    {
		$this->oSql  = $_oSql;
    }


    public function getStaticRouteList () {
		return new Yapary_Route_StaticRouteList($this->oSql);
    }
    public function getDynamicRouteList () {
    	return new Yapary_Route_DynamicRouteList($this->oSql);
    }

    /**
     * Liefert anhand der statischen und dynamischen Url das Routing-Object
     * Statische Routen werden dynamischen Routen vevorzugt
     * @param string $url 	: Url
     * @return Yapary_Route_StaticRoute|Yapary_Route_DynamicRoute|NULL
     * */
    public function getRoute ($url) {
    	$oStaticRouteList  = new Yapary_Route_StaticRouteList($this->oSql);
    	if ($oStaticRouteList->getRoute($url) != NULL) {
    		return $oStaticRouteList->getRoute($url);
    	}


    	$oDynamicRouteList = new Yapary_Route_DynamicRouteList($this->oSql);
    	if ($oDynamicRouteList->getRoute($url) != NULL) {
    		return $oDynamicRouteList->getRoute($url);
    	}


    	return NULL;
    }



}


?>